package com.sunny.hp.common.poi;

import java.util.LinkedHashMap;
import java.util.Set;

import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;

/**
 * WorkBook CellStyle Map
 * @version : 2013. 11. 14.
 * @author : �ſ�õ
 * @description : 
 * BemsWebApp / package com.feelingk.back.common;
 */

public class WBStyleCellUtil {
	LinkedHashMap<String, CellStyle> styleMap = new LinkedHashMap<String, CellStyle>();
	
	public WBStyleCellUtil(Workbook wb, LinkedHashMap<String, CellTypeInfo> cellMap){
		Set<String> keys = cellMap.keySet();
		for(String key : keys){
			CellTypeInfo info = cellMap.get(key);
			if (info.getHalign() == -1)
				info.setHalign(XSSFCellStyle.ALIGN_LEFT);
			if (info.getValign() == -1)
				info.setValign(XSSFCellStyle.VERTICAL_CENTER);

			CellStyle cellStyle = wb.createCellStyle();
			cellStyle.setAlignment(info.getHalign());
			cellStyle.setVerticalAlignment(info.getValign());
			cellStyle.setFont(info.getFont());
			
			if(info.isHeader()){
				cellStyle.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);
				cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
			}
			
			styleMap.put(key, cellStyle);
		}
	}
	
	/**
	 * @Method Name  : getCellStyle
	 * @param key
	 * @return
	 */
	public CellStyle getCellStyle(String key){
		return styleMap.get(key);
	}

}
